package study.base.arraylist;

import java.util.Arrays;

/**
 * Array工具类
 * @author : zhuxiaodong
 * @date : 2020/12/6
 */
public class Demo02 {
    //反转数组
    public static int[] reverse(int[] array){
        int[] result = new int[array.length];
        for (int i = 0; i < result.length; i++) {
            result[i] = array[array.length-1-i];
        }
        return result;
    }

    public static void main(String[] args) {
        int[] array = {1,5,9,3,7};
        Arrays.sort(array);
        System.out.println(Arrays.toString(array));
        int temp = 0;
        for(int i = 0; i < array.length - 1; i++){
            for (int j = 0; j < array.length - 1 - i; j++) {
                if(array[j] < array[j+1]){
                    temp = array[j];
                    array[j] = array[j+1];
                    array[j+1] = temp;
                }
            }
        }
        System.out.println(Arrays.toString(array));
    }
}
